package gdut.imis.advice;

import gdut.imis.Utils.Result;
import gdut.imis.enums.Status;
import gdut.imis.myexception.BusinessException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Description 统一拦截异常
 * @Author JiaFu
 * @Date 2023/4/12 13:01
 */
@RestControllerAdvice("gdut.imis.controller")
public class ExceptionAdvice {

    @ExceptionHandler({BusinessException.class})
    public Result handleBusinessException(BusinessException businessException) {
        return Result.errorWithArgs(Status.BUSINESS_EXCEPTION, businessException.getMessage());
    }

}
//    @ExceptionHandler({SQLException.class})
//    public Result handleSQLException(SQLException sqlException) {
//        return Result.errorWithArgs(Status.SQL_EXCEPTION, sqlException.getMessage());
//    }
